/*
    XTU OJ: 1183
    by: fifth_light
*/

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <math.h>
#include <limits.h>

int is_root(uint64_t num) {
    double root = sqrt(num);
    uint64_t lower = floor(root);
    uint64_t higher = ceil(root);
    return lower * lower == num || higher * higher == num;
}

// 使用uint64_t，范围在 0 ~ 1.844674407e19 间，应该够用了
// 实际上这题就是判断一个二元一次方程是否有整数解
// 连立以下方程：
// a + b = c
// a * b = d
// 得
// 0 = a ^ 2 - a * c + d
// delta = c ^ 2 - 4 * d
// 代入求根公式即可

void solve(uint64_t c, uint64_t d) {
    if (c * c == 4 * d) {
        if (c % 2 == 0) {
            uint64_t a = c / 2;
            uint64_t b = c - a;
            printf("%" PRIu64 " %" PRIu64 "\n", a, b);
        } else {
            puts("None");
        }
    } else if (c * c > 4 * d) {
        uint64_t delta = c * c - 4 * d;
        if (is_root(delta)) {
            uint64_t delta_sqrt = sqrt(delta);
            uint64_t add = c + delta_sqrt;
            uint64_t minus = c - delta_sqrt;
            uint64_t add_a = UINT64_MAX;
            uint64_t minus_a = UINT64_MAX;
            if (add % 2 == 0) {
                add_a = add / 2;
            }
            if (minus % 2 == 0) {
                minus_a = minus / 2;
            }
            uint64_t a = add_a < minus_a ? add_a : minus_a;
            uint64_t b = c - a;
            printf("%" PRIu64 " %" PRIu64 "\n", a, b);
        } else {
            puts("None");
        }
    } else {
        puts("None");
    }
}

int main(void) {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++) {
        uint64_t c, d;
        scanf("%" SCNu64 "%" SCNu64, &c, &d);
        solve(c, d);
    }
    return 0;
}
